package shared.pojo

import org.joda.time.DateTime
import shared.pojo.Pojo.{FieldValueT, ValidData}
import upickle.default._
import shared.implicits.Implicits._

/**
 * Created by yz on 13/7/2022
 */
object Sample {

  case class TestData(
                       testType: String = "",
                       company: String = ""
                     )

  object TestData {

    implicit val rw = macroRW[TestData]

  }

  case class ProcessData(
                          time: String = "",
                          title: String = "",
                          content: String = "",
                          folder: String = "",
                          fileNames: List[String] = List.empty
                        ) extends FieldValueT

  object ProcessData {

    implicit val rw = macroRW[ProcessData]

  }

  case class CommentData(
                          time: String = "",
                          method: String = "减耗",
                          amount: String = "",
                          tester: String = ""
                        ) extends FieldValueT

  object CommentData {

    implicit val rw = macroRW[CommentData]

  }

  case class LabData(
                      wareHouseTime: String = "",
                      exWareHouseTime: String = "",
                      amount: String = "",
                      compose: String = "",
                      tester: String = "",
                      sex: String = "",
                      bambooLength: String = "",
                      files: List[String] = List.empty,
                    )

  object LabData {

    implicit val rw = macroRW[LabData]

  }

  case class SampleInfo(
                         id: String = "",
                         progress: String = "",
                         workflow: List[ProcessData] = List.empty,
                         images: List[String] = List.empty,
                         serverImages: List[String] = List.empty,
                         address: String = "",
                         elevation: String = "",
                         freezerNumber: String = "",
                         gridNumber: String = "",
                         status: String = "",
                         company: String = "",
                         freezerLayerNumber: String = "",
                         rowNumber: String = "",
                         colNumber: String = "",
                         modifyTime: String = "",
                         date: String = "",
                         sampleLineNumber: String = "",
                         longitude: String = "",
                         latitude: String = "",
                         sampleType: String = "",
                         freshness: String = "",
                         gatherer: String = "",
                         weather: String = "",
                         tests: List[TestData] = List.empty,
                         comments: List[CommentData] = List.empty,
                         lab: LabData = LabData(),
                         locked: Boolean = false
                       ) extends FieldValueT

  object SampleInfo {

    implicit val rw = macroRW[SampleInfo]

  }

  case class IdStrData(id: String)

  object IdStrData {

    implicit val rw = macroRW[IdStrData]

  }

  object IdsCheck {

    case class Response(existIds: List[String])

    object Response {

      implicit val rw = macroRW[Response]

    }

  }

  case class IdStrsData(ids: List[String])

  object IdStrsData {
    implicit val rw = macroRW[IdStrsData]
  }

  case class SampleInfoNoImages(id: String, updateTime: DateTime)

  object SampleInfoNoImages {

    implicit val rw = macroRW[SampleInfoNoImages]

  }

  object ViewAppend {

    case class Request(folder: String, fileName: String, sampleId: String, testId: Int)

    object Request {

      implicit val rw = macroRW[Request]

    }

  }

  object ViewLabAppend {

    case class Request(fileName: String, sampleId: String)

    object Request {

      implicit val rw = macroRW[Request]

    }

  }

  object GetAllNoUsedId {

    case class Item(id: String, text: String)

    object Item {

      implicit val rw = macroRW[Item]

    }

    case class More(more: Boolean)

    object More {

      implicit val rw = macroRW[More]

    }

    case class Request(q: String, hasShowNum: Int, pageSize: Int)

    implicit val requestRw = macroRW[Request]

    case class Response(results: List[Item], pagination: More)

    object Response {

      implicit val rw = macroRW[Response]

    }

  }

  object AllByIds {

    case class Request(ids: List[String])

    object Request {

      implicit val rw = macroRW[Request]

    }

    case class Response(existIds: List[String])

    object Response {

      implicit val rw = macroRW[Response]

    }

  }


  case class FreezerInfo(
                          freezerNumber: String = "",
                          freezerLayerNumber: String = "",
                          rowNumber: String = "",
                          colNumber: String = "",
                          comments: List[CommentData] = List.empty
                        )

  object FreezerInfo {

    implicit val rw = macroRW[FreezerInfo]

    type Response = List[SResponse]

    case class SResponse(x: Int, y: Int, updateTime: String, sampleId: String)

    object SResponse {

      implicit val rw = macroRW[SResponse]

    }

  }

  case class BasicInfo(
                        address: String = "",
                        date: String = "",
                        sampleLineNumber: String = "",
                        longitude: String = "",
                        latitude: String = "",
                        sampleType: String = "",
                        freshness: String = "",
                        gatherer: String = "",
                        weather: String = "",
                        elevation: String = "",
                      )

  object BasicInfo {

    implicit val rw = macroRW[BasicInfo]

  }

  object Add {

    case class Request(id: String, images: List[String])

    object Request {

      implicit val rw = macroRW[Request]

    }

  }


}
